#include <assert.h>
#include <stdio.h>
#include <imbus.h>

#define NO_TEST_OBJECT_MAIN
#include "test_object.h"
#include "test_object.c"


int main (int argc, char *argv [])
{
    IMValue *value;
    Point *p;

    im_init (&argc, &argv);

    value = im_value_new ();

    im_value_set_char (value, 'A');

    if (IM_VALUE_TYPE (value) != IM_TYPE_CHAR || im_value_get_char (value) != 'A')
        printf ("value char failed.\n");

    im_value_set_uchar (value, 'A');

    if (IM_VALUE_TYPE (value) != IM_TYPE_UCHAR || im_value_get_uchar (value) != 'A')
        printf ("value uchar failed.\n");

    im_value_set_int32 (value, -12345);

    if (IM_VALUE_TYPE (value) != IM_TYPE_INT32 || im_value_get_int32 (value) != -12345)
        printf ("value int32 failed.\n");

    im_value_set_uint32 (value, 12345);

    if (IM_VALUE_TYPE (value) != IM_TYPE_UINT32 || im_value_get_uint32 (value) != 12345)
        printf ("value uint32 failed.\n");

    im_value_set_int64 (value, 0x1234567890LL);

    if (IM_VALUE_TYPE (value) != IM_TYPE_INT64 || im_value_get_int64 (value) != 0x1234567890LL)
        printf ("value int64 failed.\n");

    im_value_set_uint64 (value, 0x1234567890LL);

    if (IM_VALUE_TYPE (value) != IM_TYPE_UINT64 || im_value_get_uint64 (value) != 0x1234567890LL)
        printf ("value uint64 failed.\n");

    im_value_set_double (value, 1.2345);

    if (IM_VALUE_TYPE (value) != IM_TYPE_DOUBLE || im_value_get_double (value) != 1.2345)
        printf ("value double failed.\n");

    im_value_set_c_string (value, "Hello world!");

    if (IM_VALUE_TYPE (value) != IM_TYPE_C_STRING || strcmp (im_value_get_c_string (value), "Hello world!") != 0)
        printf ("value string failed.\n");

    im_value_set_static_c_string (value, "Hello world!");

    if (IM_VALUE_TYPE (value) != IM_TYPE_C_STRING || strcmp (im_value_get_c_string (value), "Hello world!") != 0)
        printf ("value static string failed.\n");

    p = point_new (10, 10);

    im_value_set_object (value, p);

    p = POINT (im_value_get_object (value));

    assert (p != 0);

    point_draw (p);

    p = (Point *) circle_new (15, 15, 20);

    im_value_set_object (value, p);

    p = POINT (im_value_get_object (value));

    assert (p != 0);

    point_draw (p);

    im_object_unref (value);

    return 0;
}

/*
vi:ts=4:nowrap:ai:expandtab
*/
